# coding=utf-8
from flask import jsonify, request
from app import route_api
from app.service.api.safebox import *
from app.controller.BaseControllerHelper import *

page_name = "safebox"


@route_api.my_route(page_name, "/show", methods=["POST"])
def safebox_show():
    token = request.headers.get("token")
    token = token if token else ""
    result = show_service(token)
    return jsonify(result)


@route_api.my_route(page_name, "/save", methods=["POST"])
def safebox_save():
    data = request.json
    token = request.headers.get("token")
    token = token if token else ""
    num = get_values_by_request(data, "num")
    result = save_service(token, num)
    return jsonify(result)


@route_api.my_route(page_name, "/take", methods=["POST"])
def safebox_take():
    data = request.json
    token = request.headers.get("token")
    token = token if token else ""
    num = get_values_by_request(data, "num")
    result = take_service(token, num)
    return jsonify(result)
